<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>过滤器</title>
</head>
<body>
  <div id="app">
    <h1>
      {{sfzh|hidden(2,2)}}
      <br>
    </h1>
  </div>
  <script src="vue.js"></script>
  <script>
    const vm = new Vue({
      el:"#app",
      data:{
        sfzh:'1234256'
      },
      filters:{
        hidden(val,a,b) {
          console.log(a,b)
          if(val.length<3) {
            return val;
          }
          let s1 = val.slice(0,2)
          if(val.length<6) {
            for(let i=2;i<val.length;i++) {
              s1+="*";
            }
            return s1;
          }
          let s2 = val.slice(val.length-3)
          // console.log(s2);
          for(let i=0;i<val.length-5;i++) {
            s1+="*";
          }
          s1+=s2;
          return s1
        }
      }
    })
  </script>
</body>
</html>